﻿using System;

namespace IQIGame.Onigao.GamePlay
{
    public struct EquipSort : IEquatable<EquipSort>
    {
        public int sortType;
        public bool isDesc;
        public EquipSort(int sortType, bool isDesc) : this()
        {
            this.Sync(sortType, isDesc);
        }

        public EquipSort Sync(int sortType, bool isDesc)
        {
            this.sortType = sortType;
            this.isDesc = isDesc;
            return this;
        }

        public EquipSort Sync(EquipSort other)
        {
            return this.Sync(other.sortType, other.isDesc);
        }

        public EquipSort Sync(UIEquipSortType sortType, bool isDesc)
        {
            return this.Sync((int)sortType, isDesc);
        }

        public override bool Equals(object obj)
        {
            if (obj is EquipSort other)
                return Equals(other);
            return false;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(sortType, isDesc);
        }

        public bool Equals(EquipSort other)
        {
            return this.sortType == other.sortType && this.isDesc == other.isDesc;
        }

        static public readonly EquipSort Default = new EquipSort((int)UIEquipSortType.Quality, true);

        public static bool operator ==(EquipSort lhs, EquipSort rhs) { return lhs.Equals(rhs); }
        public static bool operator !=(EquipSort lhs, EquipSort rhs) { return !(lhs == rhs); }
    }
}
